<?php

class Url_model extends CI_Model {

    function __construct() {
        parent::__construct();
        // $this->load->helper('url');    
        //parent::Model(); 
    }

    function saveUrl($data) {

        $this->db->set($data);
        $this->db->insert('short_url');
        $id = $this->db->insert_id();
        $this->db->last_query();
        $this->session->set_flashdata('msg1', 'Short URL has been created successfully');
        $this->session->set_flashdata('short', $data['short_url']);
        redirect(base_url().'shorturl');
    }

    function getUrl() {

        $this->db->select('*');
        $this->db->from('short_url');
        $this->db->limit('1');
        $this->db->order_by('id', 'DESC');
        $query = $this->db->get();
        //$this->db->last_query();
        return $query->result();
    }

}

?>